<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:insert="~{common :: commomcss}"></head>
  <body>
  <!-- navbar-->
  <div th:replace="~{common :: commonheader}"></div>
    <div class="d-flex align-items-stretch">
      <div id="sidebar" class="sidebar py-3">
        <ul th:insert="~{common :: siderul}"></ul>
      </div>
      <div class="page-holder w-100 d-flex flex-wrap">
        <div class="container-fluid px-xl-5">
          <section class="py-5">
            <div class="row">

              <!-- 个人信息
               学生 学号 班级 姓名 电子邮箱 电话 密码
               教师 工号 姓名 电子邮箱 电话 密码
               管理员 电子邮箱 电话 密码
               -->
              <div class="col-lg-12 mb-12">
                <div class="card">
                  <div class="card-header">
                    <h3 class="h6 text-uppercase mb-0">个人信息(鼠标离开即保存)</h3>
                  </div>
                  <div class="card-body">
                    <div class="form-group">
                      <label class="form-control-label text-uppercase">学号/工号/管理员编号</label>
                      <input type="email" placeholder="学号/工号/管理员编号" class="form-control" readonly="readonly" th:value="${session.user.getUserid()}">
                    </div>
                    <div class="form-group">
                      <label class="form-control-label text-uppercase">姓名</label>
                      <input type="email" placeholder="姓名" class="form-control" readonly="readonly" th:value="${session.user.getUsername()}">
                    </div>

                    <div class="form-group">
                      <label class="form-control-label text-uppercase">电子邮箱</label>
                      <input type="email" placeholder="电子邮箱" id="newemail" class="form-control" th:value="${session.user.getEmail()}" onblur="editemail()" name="email">
                    </div>
                    <div class="form-group">
                      <label class="form-control-label text-uppercase">手机号</label>
                      <input type="tel" placeholder="手机号" id="newtel" class="form-control" th:value="${session.user.getTel()}" onblur="edittel()" name="tel">
                    </div>

                  </div>
                  <!-- 修改密码-->
                  <div class="col-lg-12 mb-12">
                    <div class="card">
                      <div class="card-header">
                        <h3 class="h6 text-uppercase mb-0">修改密码(请输入原密码 在输入密码)</h3>
                      </div>
                      <div class="card-body">
                        <form method="post" th:action="@{updatePassword}">
                          <div class="form-group">
                            <label class="form-control-label text-uppercase">原密码</label>
                            <input type="password" placeholder="原密码" class="form-control" name="oldpsw">
                          </div>
                          <div class="form-group">
                            <label class="form-control-label text-uppercase">新密码</label>
                            <input type="password" placeholder="新密码" class="form-control" name="newpsw">
                          </div>
                          <div class="form-group">
                            <button type="submit" class="btn btn-primary">确认</button>
                          </div>
                        </form>
                      </div>
                    </div>
                  </div>
                </div>

              </div>

            </div>
          </section>
        </div>
      </div>
    </div>
    <!-- JavaScript files-->
    <div th:insert="~{common :: commomjs}"></div>
  </body>
<script type="text/javascript">
  function editemail() {
    var newemail = $("#newemail").val();
    $.ajax({
      url: 'updateEmail',
      data: {'newemail':newemail},
      type: 'post'
    });
  }

  function edittel() {
    var newtel = $("#newtel").val();
    $.ajax({
      url: 'updateTel',
      data: {'newtel':newtel},
      type: 'post'
    });
  }
</script>
</html>